#pragma once

using namespace System;
using namespace System::IO;
using namespace NUnit::Framework;
using namespace LatoolNet;

namespace LatoolNetTest {

	[TestFixture]
	public ref class FFTTest {
	public:

		[Test]
		void Test() {
		
			int n = 128;
			array<Complex>^ expected = gcnew array<Complex>(n);
			for (int i = 0; i < n; i++) {
				expected[i] =  Complex(Math::Cos(2 * i * Math::PI/ 32) , 0);
			}
			array<Complex>^ iexpected = FFT::Forward(expected);

			array<Complex>^ actual = FFT::Backward(iexpected);


			for (int i = 0; i < n; i++) {
				Assert::AreEqual(expected[i].Real, actual[i].Real, 1e-10, "Test: FFT");
				Assert::AreEqual(expected[i].Imag, actual[i].Imag, 1e-10, "Test: FFT");
			}

			//StreamWriter^ writer = File::CreateText("c:/fft.csv");
			//for (int i = 0; i < n; i++) {
			//	writer->Write(i + ", ");
			//	writer->Write(carray[i].Real + ", " + carray[i].Imag + ", ");
			//	writer->Write(icarray[i].Real + ", " + icarray[i].Imag + ", ");
			//	writer->WriteLine(fcarray[i].Real + ", " + fcarray[i].Imag);
			//}
			//writer->Close();

		};

	};
}
